import java.awt.*;
public class GameObj {
    //成员变量
    Image img; //图片
    int x; //坐标
    int y;
    int width = 30; //宽高
    int height = 30;
    GameWin frame; //窗口类的引用

    public GameObj(Image img, int x, int y, GameWin frame) {
        this.img = img;
        this.x = x;
        this.y = y;
        this.frame = frame;
    }

    //成员方法
    public Image getImg() {
        return img;
    }
    public void setImg(Image img) {
        this.img = img;
    }
    public int getX() {
        return x;
    }
    public void setX(int x) {
        this.x = x;
    }
    public int getY() {
        return y;
    }
    public void setY(int y) {
        this.y = y;
    }
    public int getWidth() {
        return width;
    }
    public void setWidth(int width) {
        this.width = width;
    }
    public int getHeight() {
        return height;
    }
    public void setHeight(int height) {
        this.height = height;
    }
    public GameWin getFrame() {
        return frame;
    }
    public void setFrame(GameWin frame) {
        this.frame = frame;
    }
    public GameObj() { //无参数的构造方法
    }
    public GameObj(Image img, int x, int y, int width, int height, GameWin
            frame) {//有参数的构造方法
        this.img = img;
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
        this.frame = frame;
    }
    public void paintSelf(Graphics g){ //绘制自身
        g.drawImage(img,x,y,null);//调用drawImage()方法
    }
}
